<template>
  <div>
    登录
    <van-nav-bar title="京东登录注册" left-arrow @click-left="onClickLeft" />
    <van-form @failed="onFailed">
      <van-cell-group inset>
        <!-- 通过 pattern 进行正则校验 -->
        <van-field
          v-model="value1"
          name="pattern"
          placeholder="输入手机号"
          :rules="[{ pattern, message: '请输入正确的手机号' }]"
        />
        <van-field
          v-model="password"
          type="password"
          name="pattern"
          placeholder="输入密码"
          :rules="[{ pattern: /^\d{6}$/, message: '请输入正确密码' }]"
        />
      </van-cell-group>
      <div style="margin: 16px">
        <router-link to="/my">
          <van-button
            round
            block
            type="primary"
            native-type="submit"
            :disabled="ondisabled"
            @click="onclick"
          >
            登录
          </van-button>
        </router-link>
      </div>
    </van-form>
  </div>
</template>

<script setup>
import axios from "axios";
import { ref } from "vue";
const value1 = ref({});
const password = ref({});
const pattern = /^1[3-9]\d{9}$/;

const onFailed = (errorInfo) => {
  console.log("failed", errorInfo);
};
// const ondisabled = ref(true);

axios.get("/getsjh").then((resp) => {
  console.log(777, resp);
  value1.value = resp.data.list.shoujihao;
  password.value = resp.data.list.password;
});

// const onclick = () => {
//   if (password = password) {
//     ondisabled = true;
//   }else{
//     ondisabled = false;
//   }
// };
</script>

<style lang='scss' scoped>
</style>